<!--
 * @Author: Allen
 * @Date: 2021-01-20 09:24:58
 * @Description: 抱怨身处黑暗，不如提灯前行。愿你在自己存在的地方，成为一束光，照亮世界的一角
 * @LastEditTime: 2021-02-03 14:24:02
 * @LastEditors: Allen
 * @FilePath: \WMS\src\components\wms\wmsEjectWindows\wmsDeliveryGoTwo\index.vue
 * @Additional: 出库去向弹框
-->

<template>
  <section class="carTypeConfig">
    <el-col :span="span">
      <lableName
        :style="span == 12 ? 'width:14%' : ''"
        :validrule="validrule"
        :curLabelName="curLabelName"
        :isShowLabel="isShowLabel"
        :isRequire="isRequire"
      ></lableName>
      <el-input
        :style="setInputWidth(span)"
        placeholder="请选择"
        v-model="modelText"
        :disabled="disabled"
        size="small"
        suffix-icon="el-icon-menu"
        @clear="clearCode"
        clearable
        @focus="getFocusCode"
        :readonly="readonly"
      ></el-input>
      <validateFormate :curLabelName="curLabelName" :validrule="validrule"></validateFormate>
    </el-col>
    <PartInfo
      :popupsVisible="curPopupsVisible"
      :codeField="codeField"
      :textField="textField"
      :comType="comType"
      :valueObject="curValueObject"
      :popupsKey="popupsKey"
      :code="modelCode"
      :text="modelText"
      :key="curPopupsKey"
      :isMul="isMul"
      :returnCodeField="returnCodeField"
      :returnTextField="returnTextField"
      @changeCode="getComponentCode1"
      ref="dialogComponent"
    ></PartInfo>
  </section>
</template>
<script>
import { searchInputMixins } from "@/components/mixins/searchInputMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
// import lableName from "@/components/lableName";
import PartInfo from "@/components/wms/wmsEjectWindows/wmsDeliveryGoTwo/edit";
// import validateFormate from "@/components/validateFormate";
export default {
  // 组件混入对象
  mixins: [searchInputMixins, valueObjectMixins],
  components: {
    PartInfo,
    lableName: () => import("@/components/lableName"), //标题溢出样式组件
    validateFormate: () => import("@/components/validateFormate") //校验提示样式组件
  },
  data() {
    return {
      curLabelName: this.labelName === "" ? "合作伙伴编码" : this.labelName,
      row: {}
    };
  },
  methods: {
    getComponentCode1(
      code,
      text,
      codeField,
      comType,
      popupsKey,
      textField,
      otherField,
      selectData
    ) {
      this.curPopupsVisible = false;
      this.curPopupsKey = codeField + this.$utils.generateId();
      if (!code) {
        return;
      }
      var parent = this.$utils.getHasFormFieldParentComponent(this);
      let results = selectData[0];
      this.row = selectData[0];
      for (let key in parent.formField) {
        if (results.hasOwnProperty(key)) {
          parent.formField[key] = results[key];
        }
      }
      this.$emit(
        "changeCode",
        code,
        text,
        codeField,
        comType,
        popupsKey,
        textField,
        otherField,
        selectData
      );
    },
    setInputWidth(span) {
      switch (span) {
        case 6:
          return "";
        case 12:
          return "width:85%;line-height: 38px;";
      }
    },
    // 清空输入输入框，清空整行数据
    clearCode() {
      if (this.row.OUT_STORAGE_CODE) {
        let results = this.row;
        for (let key in results) {
          results[key] = "";
        }
        var parent = this.$utils.getHasFormFieldParentComponent(this);
        for (let key in parent.formField) {
          if (results.hasOwnProperty(key)) {
            parent.formField[key] = results[key];
          }
        }
      }
    }
  }
};
</script>
